#!/usr/bin/perl
#target_mod.cgi
require './tgtman-lib.pl';

&ReadParse();

&header($text{'config_header'}, "", "index", 0, 1);

$tname = $in{'targetid'};
@tlist=&get_target_list();
$found = 0;
my $tg;
foreach $t (@tlist) {
	if($t->{'fullname'} eq $tname) {
		$found = 1;
		$tg = $t;
	}
}
if(!$found){
	print "no target selected";
}
print "<form name=modtg action=modtgt.cgi method=post>\n";
print "<table class=mode1>\n";
print "<tr><td width=120><b>$text{'target_name'}</b></td><td>$tg->{'gstr'}:<input name=tname class=text value=$tg->{'name'}></td></tr>\n";
print "<tr><td><b>$text{'config_user'}</b></td><td><input name=setaccount type='radio' value='y' onclick='on_click_setaccount_yes();'>Yes<input name=setaccount type=radio value='n' checked onclick='on_click_setaccount_no();'>No</td></tr>\n";
print "<tr><td><b>$text{'target_user'}</b></td><td><input name=tuser class=disabletext disabled=true value=$tg->{'user'}></td></tr>\n";
print "<tr><td><b>$text{'target_pwd'}</b></td><td><input name=tpwd type=password class=disabletext disabled=true></td></tr>\n";
print "<tr> </tr>";
print "<tr><td></td><td><input name=actmod type=submit class=button1 value=$text{'submit_modify'} onclick='return on_click();' disabled=true></td></tr>\n";
print "</table>\n";

print "<p><input name=actparm type=hidden value=\'\'>\n";
print "<p><input name=oldfullname type=hidden value=$tg->{'fullname'}>\n";
print "</form>\n";
&footer("index.cgi","Back");


print <<EOF;
<script>
function on_click()
{
}
function on_click_setaccount_yes()
{
	document.forms[0].tuser.disabled = false;
	document.forms[0].tpwd.disabled = false;
	document.forms[0].tuser.style.backgroundColor = "#ffffff";
	document.forms[0].tpwd.style.backgroundColor = "#ffffff";
	document.forms[0].actmod.disabled = false;
}
function on_click_setaccount_no()
{
        document.forms[0].tuser.disabled = true;
        document.forms[0].tpwd.disabled = true;
	document.forms[0].actmod.disabled = true;
        document.forms[0].tuser.style.backgroundColor = "#d4d0c8";
        document.forms[0].tpwd.style.backgroundColor = "#d4d0c8";
	document.forms[0].tuser.value = "";
	document.forms[0].tpwd.value = "";
}
</script>
EOF
